<?php

namespace app\common\model\mall\shop;

use think\Model;

class Set extends Model
{
    // 表名
    protected $name = 'mall_shop_set';

    protected $pk = 'shop_id';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    
    // 追加属性
    protected $append = [

    ];

    public function getBannerAttr($value, $data)
    {
        $mallcdn = config("mall.mallcdn");
        if($mallcdn && !stristr($value,$mallcdn))
            return $mallcdn ? $mallcdn.$value : cdnurl($value);
        else
            return cdnurl($value);
    }

    public function getAdsAttr($value, $data){
        if($value) {
            $value = explode(",", $value);
            foreach ($value as $k=>$v){
                $value[$k] = config("mall.mallcdn") ? config("mall.mallcdn").$v : cdnurl($v);
            }
            $value = implode(',',$value);
        }
        return $value;
    }

}
